﻿#include "custom_data.h"
#include <iostream>
#include <thread>

using namespace boost::interprocess;

int main()
{
    // struct shm_remove {
    //     shm_remove() {
    //         shared_memory_object::remove("my_shared_memory");
    //     }
    //     ~shm_remove() {
    //         shared_memory_object::remove("my_shared_memory");
    //     }
    // } remover;

    managed_shared_memory segment(open_or_create, "my_shared_memory", 524288000);
    custom_data data;
    data.init(segment);

    std::string base_str = "test_str_";
    while (true)
    {
        // 生成随机数
        int num = rand() % 100;
        data.push_back(num);
        std::this_thread::sleep_for(std::chrono::seconds(1));
    }

    return 0;
}